package com.yuma.origin;

import lombok.Data;

// 1.实现空接口Cloneable
public class Person implements Cloneable{
    private String name;
    private Dog dog;

    // 2.重写clone方法
    @Override
    protected Object clone() throws CloneNotSupportedException {
//        return super.clone();
        Person p = new Person();
        p.setName(this.getName());
        Dog d = new Dog();
        d.setName(dog.getName());
        p.setDog(d);
        return p;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Dog getDog() {
        return dog;
    }

    public void setDog(Dog dog) {
        this.dog = dog;
    }
}
